﻿using HAF.LogUtility.Assistantor;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using XmlUtility.Model;

namespace XmlUtility
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void btnReadXml_Click(object sender, EventArgs e)
        {
            string filePath = txtPath.Text;
            if (Path.GetExtension(filePath).ToUpper().Equals(".JSON"))
            {
                if (File.Exists(filePath))
                {
                    List<GatherRuleConfig> gatherRules = JsonAssistant.FromFile<List<GatherRuleConfig>>(filePath);
                    if (gatherRules != null && gatherRules.Count > 0)
                    {

                    }
                }
            }
            else
            {
                XmlAssistantor xmlObj = new XmlAssistantor();
                //txtContent.Text = xmlObj.ReadXmlElement(txtPath.Text);
                //txtContent.Text = xmlObj.ReadXmlNode(txtPath.Text);
                var bbb = xmlObj.ReadXmlObjects<RequestResult>(txtPath.Text, "http://smc.huawei.com/", "LoginRequestResult");

                var ccc = xmlObj.ReadXmlObjects<LoginRequestResponse>(txtPath.Text, "http://smc.huawei.com/", "LoginRequestResponse");
                //string xmlContent = "<LoginRequestResponse xmlns=\"http://smc.huawei.com/\"><LoginRequestResult>\r\n <ErrCode>0</ErrCode> <Description>0</Description></LoginRequestResult><randomSequence>07170DPd5UKeBCYeLIbsBw==</randomSequence></LoginRequestResponse>";
                //var aaa = xmlObj.DeSerialize<LoginRequestResponse>(xmlContent.Replace(" xmlns=\"http://smc.huawei.com/\"", ""));
            }

        }
    }
}
